package com.study.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.study.DateUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * (Product)实体类
 *
 * @author dujun
 * @since 2020-10-20 10:34:49
 */
public class Product implements Serializable {
    private static final long serialVersionUID = -98660058110617736L;
    /**
     * 主键，自动增长
     */
    private Integer id;
    /**
     * 产品编号
     */
    private String productnum;
    /**
     * 产品名称（路线名称）
     */
    private String productname;
    /**
     * 出发城市
     */
    private String cityname;
    /**
     * 出发时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date departuretime;

    /**
     * 字符串类型日期
     */
    private String departuretimeStr;

    public String getDeparturetimeStr() {
        String dateStr = null;
        if(departuretime != null){
             dateStr = DateUtils.date2String(this.departuretime, "yyyy-MM-dd HH:mm:ss");
        }
        return dateStr;
    }

    public void setDeparturetimeStr(String departuretimeStr) {
        this.departuretimeStr = departuretimeStr;
    }

    /**
     * 产品价格
     */
    private Double productprice;
    /**
     * 产品描述
     */
    private String productdesc;
    /**
     * 状态（0关闭1开启）
     */
    private Integer productstatus;
    /**
     * 字符串类状态
     */
    private String productstatusStr;

    public String getProductstatusStr() {
        String statusStr = null;
        if (productstatus != null) {
            if (productstatus == 0){
                statusStr = "关闭";
            }
            else if(productstatus == 1){
                statusStr = "开启";
            }
        }
        return statusStr;
    }

    public void setProductstatusStr(String productstatusStr) {
        this.productstatusStr = productstatusStr;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getProductnum() {
        return productnum;
    }

    public void setProductnum(String productnum) {
        this.productnum = productnum;
    }

    public String getProductname() {
        return productname;
    }

    public void setProductname(String productname) {
        this.productname = productname;
    }

    public String getCityname() {
        return cityname;
    }

    public void setCityname(String cityname) {
        this.cityname = cityname;
    }

    public Date getDeparturetime() {
        return departuretime;
    }

    public void setDeparturetime(Date departuretime) {
        this.departuretime = departuretime;
    }

    public Double getProductprice() {
        return productprice;
    }

    public void setProductprice(Double productprice) {
        this.productprice = productprice;
    }

    public String getProductdesc() {
        return productdesc;
    }

    public void setProductdesc(String productdesc) {
        this.productdesc = productdesc;
    }

    public Integer getProductstatus() {
        return productstatus;
    }

    public void setProductstatus(Integer productstatus) {
        this.productstatus = productstatus;
    }

}